package com.amit.Basic_Simple_Program;

import java.util.Scanner;

public class Bubble__Sort {

	public static void main(String[] args) {
		
		int a[],n,c,swap;
		
		System.out.println("Enter the number for array element");
		
		Scanner sc=new Scanner(System.in);
		 n=sc.nextInt();
		 
		 a=new int[n];
		 
		 System.out.println("Enter the element for array");
		 
		 for(c=0;c<n;c++)
		 
			 a[c]=sc.nextInt();
			 
			 for(c=0;c<n-1;c++)
			 {
				 for(int d=0;d<n-c-1;d++)
				 {
					 if(a[d]>a[d+1])
					 {
						 swap=a[d];
						 a[d]=a[d+1];
						 a[d+1]=swap;
					 }
				 }
			 }
			 
		 
		 
		 System.out.println("Sorted array");
		 
		 for(int i=0;i<=a.length-1;i++)
		 {
			 System.out.println(a[i]);
		 }
		 
		
		

	}

}
